package com.demo.flight.controller;

import com.demo.flight.config.Result;
import com.demo.flight.config.ResultCodeEnum;
import com.demo.flight.entity.RefundTicket;
import com.demo.flight.entity.Ticket;
import com.demo.flight.service.RefundTicketService;
import com.demo.flight.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author ssy
 * @create 2022-03-25 10:58
 */


@CrossOrigin
@ResponseBody
@Controller
@RequestMapping("/ticket")
public class TicketController {
    
    @Autowired
    private TicketService ticketService;
    
    @Autowired
    private RefundTicketService refundTicketService;
    
    @GetMapping("/get/tickets")
    public Result getTickets() {
        List<Ticket> ticketList = ticketService.getAll();
        return Result.success(ticketList, ResultCodeEnum.SUCCESS);
    }
    
    @GetMapping("/get/refundTickets")
    public Result getRefundTickets() {
        List<RefundTicket> refundTicketList = refundTicketService.getAll();
        return Result.success(refundTicketList, ResultCodeEnum.SUCCESS);
    }
    
}
